<template>
  <section>
    <asn-banner :banner-list="bannerList"></asn-banner>
    <section class="ranking-section">
      <el-tabs v-model="activeRanking" @tab-click="handleTabClick">
        <el-tab-pane label="职业战队" name="proPlayer">
          <ProPlayerRanking :rankList="rankList"/>
        </el-tab-pane>
        <el-tab-pane label="职业选手" name="proTeam">
          <ProTeamRanking :occupation="occupation"/>
        </el-tab-pane>
        <el-tab-pane label="普通选手" name="normalPlayer">
          <NormalPlayerRanking :commonList="commonList"/>
        </el-tab-pane>
      </el-tabs>
    </section>
  </section>
</template>

<script>
import ProPlayerRanking from "./components/ProPlayerRanking.vue";
import ProTeamRanking from "./components/ProTeamRanking.vue";
import NormalPlayerRanking from "./components/NormalPlayerRanking.vue";
import AsnBanner from "../../component/AsnBanner.vue";
import { getAsyncList } from "@/api/rank.js";
import {getOccupationAsync} from "@/api/occupation.js"
import { getCommonAsync } from "@/api/common.js";
 
export default {
  components: {
    ProPlayerRanking,
    ProTeamRanking,
    NormalPlayerRanking,
    AsnBanner,
  },
  data() {
    return {
      activeRanking: "proPlayer",
      bannerList: [
        {
          id: 1,
          img: require("@/public/img/banner01.jpg"),
        },
        {
          id: 2,
          img: require("@/public/img/banner02.jpg"),
        },
        {
          id: 3,
          img: require("@/public/img/banner03.jpg"),
        },
      ],
      rankList:[],
      occupation:[],
      commonList:[]
    };
  },
  methods: {
    handleTabClick(tab) {
      console.log("切换到:", tab.name);
    },

    async getRankList (){
      try{
        const { data } = await getAsyncList();
        this.rankList = data;        
      }catch(err){

      }
    },

    async getOccupationAsync(){
      try{
        const { data } = await getOccupationAsync();        
        this.occupation = data;
      }catch(err){

      }
    },

    async getCommonAsync(){
      try{
        const { data } = await getCommonAsync();
        this.commonList = data;        
      }catch(err){

      }

    }
  },
  created() {
    this.getRankList();
    this.getOccupationAsync();
    this.getCommonAsync();
  },
};
</script>

<style scoped>
.ranking-section {
  /* background-color: #0a1f3d; */
  color: #00e4ff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 0 15px rgba(0, 228, 255, 0.1);
}

.el-tabs__nav-wrap::after {
  background-color: transparent !important;
}

.el-tabs__item {
  color: #00e4ff;
  font-weight: bold;
}

.el-tabs__item.is-active {
  color: #ffffff;
}

.el-tabs__active-bar {
  background-color: #00e4ff;
}
</style>